package User

import (
	"net/http"

	M "ICan/MySql"
	"ICan/errmsg"
	_ "github.com/go-sql-driver/mysql"
	"github.com/gin-gonic/gin"
)

type collection struct {
	Animation_id string `json:"animation_id"`
}

func FCollection(ctx *gin.Context){
	user_id := ctx.PostForm("user_id")
	sqlstr := `select collection_animation_id from collection where collection_user_id = ?`
	rows, _ := M.Db.Query(sqlstr, user_id)
	defer rows.Close()
	var coll = make([]collection, 0)
	for rows.Next() {
		var u collection
		rows.Scan(&u.Animation_id)
		coll = append(coll, collection{
			Animation_id:u.Animation_id,
		})
	} 
	code := errmsg.Succse
	data := map[string]interface{}{
		"code":code,
		"msg":errmsg.GetErrMSg(code),
		"data":coll,
	}
	ctx.JSON(http.StatusOK, data)
}
